<template>
	<view>
		<!-- <uni-nav-bar left-icon="back" left-text="" right-text="" title='等待付款'></uni-nav-bar> -->
		<view class="paying">
			支付中...
		</view>
		<view class="order-list">
			<view class="orderitem">
				<view class="top">
					<text>订单编号:{{datalist.order.orderSn}}</text>
					<text class="status">{{datalist.order.status}}</text>
				</view>
				<view class="con" v-for="con in datalist.items" :key='con.id'>
					<image :src="con.productPic" mode=""></image>
					<view class="info">
						<view class="left">
							<view class="title">{{con.productName}}</view>
							<view class="">编号: 123456789</view>
							<view class="">规格: 暂无</view>
							<view class="color">颜色: {{JSON.parse(con.productAttr)[0].value ? JSON.parse(con.productAttr)[0].value : '暂无'}}</view>
						</view>
						<view class="left right">
							<view class="title">￥{{con.productPrice}}</view>
							<view class="">X{{con.productQuantity}}</view>
						</view>
					</view>
				</view>
				<view class="bottom">
					<text>时间:{{datalist.order.createTime}}</text>
					<text>合计: ￥{{datalist.order.totalAmount}}</text>
				</view>
			</view>
		</view>
		<button type="default" @click="payfor">确认付款</button>
	</view>
</template>

<script>
	import {
		payConfirm
	} from "../../../../api/my/waitpay/waitpay.js"
	import datalist from '../../../../data/city.js'
	export default {
		data() {
			return {
				datalist: ''
			};
		},
		methods: {
			payfor() {
				console.log(this.datalist.order.orderSn);
				payConfirm({
					token: uni.getStorageSync('token'),
					orderId: this.datalist.order.orderSn
				}).then(res => {
					console.log(res);
					if (res.success) {
						uni.showToast({
							title: "支付成功"
						})
						// setTimeout(uni.navigateBack(),1000)
						setTimeout(function() {
							uni.navigateBack()
						}, 1700)
					}

				})

			}
		},
		onLoad(e) {
			console.log(e);
			console.log(datalist.arr.data.orderList);
			var arr1 = datalist.arr.data.orderList
			var index = arr1.findIndex(el => {
				return el.order.orderSn == e.id
			})
			console.log(index);
			this.datalist = arr1[index]
			this.datalist.order.status = '待付款'
			console.log(arr1[index]);
		}
	}
</script>

<style lang="scss" scoped>
	button {
		width: 710rpx;
		margin: 0 auto;
		background-color: #fff;
		box-sizing: border-box;
	}

	.paying {
		width: 710rpx;
		margin: 0rpx auto;
		margin-bottom: 20rpx;
		margin: 20rpx;
		text-indent: 20rpx;
		border-bottom: 2rpx solid #e5e5e5;
		background-color: #fff;
		border-radius: 12rpx;
		line-height: 106rpx;
		box-sizing: border-box;
	}

	.orderitem {
		width: 710rpx;
		background-color: #FFFFFF;
		border-radius: 20rpx;
		box-sizing: border-box;
		padding: 20rpx 20rpx;
		margin: 40rpx auto;

		.top {
			display: flex;
			justify-content: space-between;
			padding: 18rpx 0;
			border-bottom: 2rpx solid #eee;
			box-sizing: border-box;
			font-size: 24rpx;
			color: #3e3e3e;

			.status {
				color: #034c46;
				box-sizing: border-box;
			}
		}

		.con {
			padding: 30rpx 0;
			display: flex;
			justify-content: space-between;
			box-sizing: border-box;
			border-bottom: 2rpx solid #eee;

			image {
				width: 160rpx;
				height: 160rpx;
				border-radius: 20rpx;
				box-sizing: border-box;
			}

			.info {
				width: 460rpx;
				display: flex;
				justify-content: space-between;
				margin-bottom: 20rpx;
				box-sizing: border-box;

				.left {
					font-size: 22rpx;
					line-height: 30rpx;
					color: #8d8d8d;
					box-sizing: border-box;

					.title {
						width: 400rpx;
						font-size: 26rpx;
						color: #3e3e3e;
						line-height: 58rpx;
						overflow: hidden;
						text-overflow: ellipsis;
						box-sizing: border-box;
						white-space: nowrap;
					}
				}

				.right {
					text-align: right;
					box-sizing: border-box;
				}
			}
		}

		.bottom {
			padding: 20rpx 0;
			display: flex;
			box-sizing: border-box;
			justify-content: space-between;
			font-size: 26rpx;
			line-height: 36rpx;
		}

		.btns {
			padding: 12rpx 0;
			height: 80rpx;
			box-sizing: border-box;

			.btn {
				height: 54rpx;
				line-height: 50rpx;
				float: right;
				margin-left: 20rpx;
				box-sizing: border-box;
				font-size: 24rpx;
				border: 1px solid #2d4f43;
				color: #2d4f43;
				background-color: rgba(0, 0, 0, 0);
			}
		}

	}

	.orderitem {
		margin-top: 20rpx;
		box-sizing: border-box;
	}
</style>
